#include "BlockModel.h"
#include "UpdateBlockNetworkEvent.h"

BlockModel::BlockModel(const Position& position)
    : position(position), newPosition(position)
{
}

BlockModel::~BlockModel()
{
}

Position BlockModel::getPosition()
{
    return newPosition;
}

void BlockModel::updateClients()
{
    if (position != newPosition)
    {
        position = newPosition;
        addChangeEvent(new UpdateBlockNetworkEvent(id, position));
    }
}

void BlockModel::rotateCWAround(const Position& origin)
{
    newPosition = position.rotateCWAround(origin);
}

void BlockModel::rotateCCWAround(const Position& origin)
{
    newPosition = position.rotateCCWAround(origin);
}

void BlockModel::reset()
{
    newPosition = position;
}
